package com.geostar.constructionland.common.service.dict.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.geostar.constructionland.common.entity.dict.JsydDicEntry;
import com.geostar.constructionland.common.mapper.dict.JsydDicEntryMapper;
import com.geostar.constructionland.common.service.dict.JsydDicEntryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <接口或类描述>
 *
 * @author chenjianjun
 * @since 2020-09-09 15:04
 */
@Service
public class JsydDicEntryServiceImpl extends ServiceImpl<JsydDicEntryMapper, JsydDicEntry>
                implements JsydDicEntryService {
    private JsydDicEntryMapper jsydDicEntryMapper;

    @Autowired
    public JsydDicEntryServiceImpl(JsydDicEntryMapper jsydDicEntryMapper) {
        this.jsydDicEntryMapper = jsydDicEntryMapper;
    }

    @Override
    public Map<String, String> getDictMap(String dictTypeId) {
        Map<String, String> result = new HashMap<>();
        QueryWrapper<JsydDicEntry> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dicttypeid", dictTypeId);
        List<JsydDicEntry> dicEntryList=jsydDicEntryMapper.selectList(queryWrapper);
        for(JsydDicEntry dicEntry:dicEntryList){
            result.put(dicEntry.getDictName(),dicEntry.getDictId());
        }
        return result;
    }
}

